package top.techqi.core.util

import top.techqi.core.tool.xlog.ILog
import top.techqi.core.tool.xlog.impl.CommLog

/** 日志工具类 */
@Suppress("unused")
object LogUtil : ILog {
    private val logs = mutableSetOf<ILog>(CommLog)

    operator fun plusAssign(log: ILog) {
        logs.add(log)
    }

    operator fun minusAssign(log: ILog) {
        logs.remove(log)
    }

    override fun v(tag: String, msg: String) {
        logs.forEach { it.v(tag, msg) }
    }

    override fun v(tag: String, msg: String, tr: Throwable?) {
        logs.forEach { it.v(tag, msg, tr) }
    }

    override fun d(tag: String, msg: String) {
        logs.forEach { it.d(tag, msg) }
    }

    override fun d(tag: String, msg: String, tr: Throwable?) {
        logs.forEach { it.d(tag, msg, tr) }
    }

    override fun i(tag: String, msg: String) {
        logs.forEach { it.i(tag, msg) }
    }

    override fun i(tag: String, msg: String, tr: Throwable?) {
        logs.forEach { it.i(tag, msg, tr) }
    }

    override fun w(tag: String, msg: String) {
        logs.forEach { it.w(tag, msg) }
    }

    override fun w(tag: String, msg: String, tr: Throwable?) {
        logs.forEach { it.w(tag, msg, tr) }
    }

    override fun e(tag: String, msg: String) {
        logs.forEach { it.e(tag, msg) }
    }

    override fun e(tag: String, msg: String, tr: Throwable?) {
        logs.forEach { it.e(tag, msg, tr) }
    }
}
